<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <title>Document</title>
  <style>

  </style>
</head>

<body>
  <button>添加</button>
  <script src="./axios.js"></script>
</body>
<script>
  document.querySelector('button').addEventListener('click', function () {
    //单击按钮之后,这里发送ajax请求,添加数据
    axios({
      method: 'POST',//添加数据
      url: 'http://www.itcbc.com:3006/api/addbook',
      data: {
        bookname: '爱小甜瓜',
        author: '吱吱',
        publisher: '爱小甜瓜出版社',
        appkey: 'zhizhi0208'
      }
    }).then(({ data: res }) => {
      console.log(res);//输出服务器返回的结果
    })
  })
</script>

</html>